<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="modal fade" data-backdrop="static" data-keyboard="false" id="modal-merge">
    <div class="modal-dialog" style="width:1400px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">合报记录</h4>
            </div>
            <div class="modal-body">
                <form id="mergeForm" class="form-horizontal">
                    <input type="hidden" id="rppIdm" name="id">
                    <!--type="hidden"-->
                    <div style="float: left; width: 100%; height:0px" class="form-group">
                        <div class="row">
                            <div class="col-xs-12" style="padding-bottom: 10px">
                                <div class="form-inline">
                                    <div class="form-group" style="margin-right: 2px;">
                                        <label style="width: 100px;text-align: right">项目编号：</label>
                                        <label name="rppProjectCode" style="margin-left:5px;margin-right: 20px"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 80px; margin-left:20px">
                                        <label>项目名称：</label>
                                        <label style="font-size: 14px;" name="projectName"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 50px">
                                        <label>提报计划物料描述：</label>
                                        <label id="merge"></label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div hidden>
                        </div>
                    </div>
                </form>
                <div class="box-body">
                    <table id="bootstrap-table5"></table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<section class="content-header"><h1>采购计划综合查询</h1></section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label>物料描述</label>
                                    <input type="text" name="sppMatDesc" class="form-control" placeholder="请输入提报或采购物料">
                                </div>
                                <div class="form-group">
                                    <label>SAP物料编码</label>
                                    <input type="text" name="sppSapCode" class="form-control" placeholder="请输入SAP物料编码">
                                </div>
                                <div class="form-group">
                                    <label>项目编号</label>
                                    <input type="text" name="rppProjectCode" class="form-control" placeholder="请输入项目编号">
                                </div>
                                <div class="form-group">
                                    <label>项目名称</label>
                                    <input type="text" name="rppProjectName" class="form-control" placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label>跟踪号</label>
                                    <input type="text" name="sppTrackCode" class="form-control" placeholder="请输入跟踪号">
                                </div>
                                <div class="form-group">
                                    <label>计划员</label>
                                    <input type="text" name="rppPlanner" class="form-control" placeholder="请输入计划员">
                                </div>
                                <div class="form-group">
                                    <label>计划号</label>
                                    <input type="text" name="rppPlanNo" class="form-control" placeholder="请输入计划号">
                                </div>
                                <div class="form-group">
                                    <label>提报状态</label>
                                    <select name="rppUseStock" multiple
                                            class="form-control selectpicker"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width:auto!important;"
                                            data-actions-box="true">
                                        <option value="2" selected="selected">正常采购</option>
                                        <option value="1" selected="selected">使用库存</option>
                                        <option value="3" selected="selected">暂不提报</option>
                                        <option value="4" selected="selected">甲供</option>
                                    </select>
                                    <input name="rppUseStockStr" type="hidden" style="display: none" value="2,1,3,4">
                                </div>
                                <div class="form-group">
                                    <label>合报标识</label>
                                    <select name="sppIntegraFlag" class="form-control">
                                        <option value="" selected="selected">全部</option>
                                        <option value="1">合报计划</option>
                                        <option value="2">普通计划</option>
                                    </select>
                                </div>

                                <!--<div class="form-group">
                                    <label>品牌</label>
                                    <input type="text" name="sppBrand" class="form-control" placeholder="">
                                </div>
                                <div class="form-group">
                                    <label>备注</label>
                                    <input type="text" name="sppRemark" class="form-control" placeholder="">
                                </div>-->
                                <!--<div class="form-group">-->
                                <!--<label>生产状态</label>-->
                                <!--<select name="proProductionStatus" class="form-control">-->
<!--                                <option value="" selected="selected">全部</option>-->
<!--                                <option value="-1">无状态</option>-->
<!--                                <option value="1">未开始</option>-->
<!--                                <option value="2">执行中</option>-->
<!--                                <option value="3">已完成</option>-->
<!--                                <option value="4">取消</option>-->
<!--                                <option value="5">暂缓</option>-->
                                <!--</select>-->
                                <!--</div>-->
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>生产状态</label>
<!--                                    <select name="proProductionStatusList" class="form-control selectpicker" multiple-->
<!--                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width:auto!important;"-->
<!--                                            data-actions-box="true">-->
<!--                                        <option value="0" selected="selected">无状态</option>-->
<!--                                        <option value="1" selected="selected">制作中</option>-->
<!--                                        <option value="2" selected="selected">待制作</option>-->
<!--                                        <option value="3" selected="selected">暂缓</option>-->
<!--                                        <option value="4" selected="selected">完成</option>-->
<!--                                    </select>-->
<!--                                    <input name="proProductionStatusListText" style="display: none"/>-->
                                    <select name="proProductionStatus" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width:auto!important;">
                                        <option value="" selected="selected">全部</option>
                                        <option value="-1">无状态</option>
                                        <option value="1">未开始</option>
                                        <option value="2">执行中</option>
                                        <option value="3">已完成</option>
                                        <option value="4">取消</option>
                                        <option value="5">暂缓</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>采购进度</label>
                                    <select name="sppStatusList" class="form-control selectpicker"
                                            multiple
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: auto!important;"
                                            data-actions-box="true">
                                        <option value="0" selected="selected">未采购</option>
                                        <option value="1" selected="selected">计划编辑中</option>
                                        <option value="2" selected="selected">未审阅</option>
                                        <option value="3" selected="selected">未导入OA</option>
                                        <option value="4" selected="selected">OA审核中</option>
                                        <option value="5">OA审核通过</option>
                                        <option value="6">OA审核不通过</option>
                                    </select>
                                    <input name="sppStatusListText" value="0,1,2,3,4" style="display: none"/>
                                </div>
                                <!--<div class="form-group">-->
                                <!--<label>采购日期</label>-->
                                <!--<input type="text" class="form-control datepicker" name="startTime"-->
                                <!--readonly="readonly"/>-->
                                <!--<span> 至 </span>-->
                                <!--<input type="text" class="form-control datepicker" name="endTime"-->
                                <!--readonly="readonly"/>-->
                                <!--</div>-->
                                <button type="button" class="btn btn-success" id="btn-search">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    var table;
    var reportStatusName = ['', '使用库存', '正常采购', '暂不提报', '甲供'],
        shopStatusName = ['', '未提交', '未审批', '未导入', '未审核', '审核通过', '审核不通过'],
        proStatusName = ['无状态', '执行中', '未开始', '暂缓', '已完成','取消'];
    var changeStatusName = ['未变更', '变更'];
    var shopStatusName = ['未采购', '计划编辑中', '未审阅', '未导入OA', 'OA审核中', '审核通过', '审核不通过'];
    var proStatusName = ['无状态', '执行中', '未开始', '暂缓', '已完成', '取消'];
    var colors = ['', "label-warning", "label-success", "label-danger", "label-info"];
    var colors1 = ['', "label-warning", "label-info", "label-primary", "label-warning", "label-success", "label-danger"];
    var colors2 = ['', "label-warning", "label-default", "label-danger", "label-success", "label-danger"];

    /**
     * 查看合报记录
     */
    function openMerge(rppId) {
        var rowData = $('#bootstrap-table').bootstrapTable('getRowByUniqueId', rppId)
        $('#rppIdm').val(rowData.rppId);
        $('#merge').text(rowData.rppMatDesc);
        $("#mergeForm [name='rppProjectCode']").text(rowData.rppProjectCode);
        $("#mergeForm [name='projectName']").text(rowData.rppProjectName);

        table4 = js.table.init({
            showColumns: false,
            id: "bootstrap-table5",
            queryForm: "mergeForm",
            url: ctx + "buy/planTraManage/merPurchasingOpen",
            showExport: false,
            columns: [
                {
                    title: '序号', field: 'id', width: '40',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {
                    title: '提报物料描述', field: 'rppMatDesc', width: '180',
                    formatter: function (value, row, index) {
                        return '<p  style="word-wrap: break-word;width: 170px">' + value + '</p>';
                    }
                },
                {title: '提报数量', field: 'rppNum', width: '40'},
                {title: '提报单位', field: 'rppUnit', width: '40'},
                {title: '标准号', field: 'rppStandardNo', width: '100'},
                {title: '提报项目编号', field: 'rppProjectCode', width: '60'},
                {
                    title: '提报项目名称', field: 'rppProjectName', width: '180',
                    formatter: function (value, row, index) {
                        return '<p  style="word-wrap: break-word;width: 170px">' + value + '</p>';
                    }
                },
                {title: '计划号', field: 'rppPlanNo', width: '80'},
                {title: '提报时间', field: 'rppCreateTime', width: '80'},
                {title: '合报后项目编号', field: 'sppProjectCode', width: '60'},
                {title: '合报后项目名称', field: 'sppProjectName', width: '180'},

            ]
        });
        js.modal.open("modal-merge");
        js.table.refresh(table4);

    }

    $(function () {
        $("#queryForm [name='rppUseStock']").change(function () {
            $("#queryForm input[name='rppUseStockStr']").val($("#queryForm [name='rppUseStock']").val());
        });

        $("title").html($("title").html()+" —— 合报记录");
        /** 综合查询表格 */
        table = js.table.init({
            showColumns: false,
            showExport: false,
            url: ctx + "buy/integrateQuery/list",
            uniqueId: "rppId",
            // 数量、单位、项目号、项目信息有采购计划信息显示采购计划信息、没有显示提报计划信息
            columns: [
                {
                    title: '序号', field: 'id', width: '50px',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {
                    title: "项目号", field: 'rppProjectCode',
                    formatter: function (value, row, index, field) {
                        return value ? value : row.rppProjectCode;
                    }
                },
                {
                    title: "项目信息", field: 'rppProjectName',
                    formatter: function (value, row, index, field) {
                        return value ? value : row.rppProjectName;
                    }
                },
                {
                    title: "提报计划<br>物料描述", field: 'rppMatDesc', width: '150',
                    formatter: function (value, row, index) {
                        return '<p  style="word-wrap: break-word;width: 140px">' + value + '</p>';
                    }
                },
                {
                    title: "提报计划<br>是否拆分", field: 'rppOriginalFlag',
                    formatter: function (value, row, index, field) {
                        if (value == null || value == undefined) {
                            return "-";
                        }
                        return value == 2 ? '<span class="badge label-success">是</span> ' : '<span class="badge label-warning">否</span> ';
                    }
                },
                {
                    title: "sap<br>物料编码", field: 'sppSapCode', formatter: function (value, row, index) {
                        if (value == null && row.itySapCode == null) {
                            return "-";
                        }
                        if (value == null && row.itySapCode != null) {
                            return row.itySapCode;
                        }

                        return value;

                    }
                },
                {
                    title: "采购物料描述<br>(指定库存物料)", field: 'sppMatDesc', width: '150',
                    formatter: function (value, row, index) {
                        if (value == null || value == undefined) {
                            return "-";
                        }
                        return '<p  style="word-wrap: break-word;width: 140px">' + value + '</p>';
                    }
                },
                {
                    title: "数量", field: 'sppNum',
                    formatter: function (value, row, index, field) {
                        return value ? value : row.rppNum;
                    }
                },
                {
                    title: "单位", field: 'sppUnit',
                    formatter: function (value, row, index, field) {
                        return value ? value : row.rppUnit;
                    }
                },
                {title: "跟踪号", field: 'sppTrackCode'},
                {
                    title: "计划员 ", field: 'rppPlanner',
                    formatter: function (value, row, index, field) {
                        return value!=null ? value : '';
                    }
                },
                {
                    title: "计划号 ", field: 'rppPlanNo',
                    formatter: function (value, row, index, field) {
                        return value!=null ? value : '';
                    }
                },
                {
                    title: "提报状态", field: 'rppUseStock', width: '90px;',
                    formatter: function (value, row, index, field) {
                        if (value) {
                            return '<span class="badge ' + colors[value] + '">' + reportStatusName[value] + '</span> ';
                        }
                    }
                },
                // { title: "供应商", field: 'sppSupplier'},
                // { title: "品牌", field: 'sppBrand'},
                // { title: "备注", field: 'sppRemark'},

                {
                    title: "采购进度", field: 'sppStatus', width: '90px;',
                    formatter: function (value, row, index, field) {
                        if (value == null) {
                            value = 0;
                        }

                        return '<span class="badge ' + colors1[value] + '">' + shopStatusName[value] + '</span> ';

                    }
                },
                {title: "审批日期", field: 'sppVerifyDate', width: '80px'},
                {
                    title: "生产状态", field: 'proProductionStatus',
                    formatter: function (value, row, index, field) {


                        return '<span class="badge ' + colors2[value] + '">' + proStatusName[value] + '</span>';

                    }
                },
                {
                    title: "变更标识", field: 'sppChangeStatus',
                    formatter: function (value, row, index, field) {
                        if (value || value === 0) {
                            return changeStatusName[value];
                        }
                    }
                },
                {
                    title: '操作', width: '100px',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.sppIntegraFlag == 1) {
                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="openMerge(' + row.rppId + ')"> 合报记录</a> ');
                        }
                        return actions.join('');
                    }
                }
            ]
        });

        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });

        $("#queryForm [name='proProductionStatusList']").change(function () {
            $("#queryForm [name='proProductionStatusListText']").val($("#queryForm [name='proProductionStatusList']").val());
        });
        $("#queryForm [name='sppStatusList']").change(function () {
            $("#queryForm [name='sppStatusListText']").val($("#queryForm [name='sppStatusList']").val());
        });
    });

</script>
</body>
</html>
